Click here to Skip to main content
15,889,034 members
Articles / Programming Languages / MSIL

.NET – 5 Free Decompilers

Rate me:
Please Sign up or sign in to vote.
4.96/5 (36 votes)
2 Mar 2023CPOL6 min read 56.4K   53   23
Overview of 5 free .NET Decompilers
This articles gives an overview of 5 free .NET Decompilers. We are focusing only on free tools that you can run for free in both non-commercial and commercial environments.

1. Introduction

In this article, we are giving an overview of a selection of FREE .NET Decompilers available today. We focus only on completely free full-versions tools, that can be run for free in both non-commercial and commercial environments. If a software engineer invests time and effort in learning and building skills with some tool at home that is free only for a non-commercial environment, and then in his workplace finds that the company is not planning to buy that particular tool, it is wasted time and effort.

1.1. Tools Tested

Here is a list of free .NET Decompilers that caught our attention:

  1. Ildasm.exe (comes with Visual Studio 2022)
  2. Telerik JustDecompile (https://www.telerik.com/products/decompiler.aspx )
  3. dnSpyEx (https://github.com/dnSpyEx/dnSpy/releases )
  4. ILSpy (https://github.com/icsharpcode/ILSpy/releases )
  5. JetBrains dotPeek (https://www.jetbrains.com/decompiler/ )

2. Test Application

In order to test decompilers, we created a small C#11/.NET7 project consisting of 2 assemblies. Here is what the solution looks like:

Image 1

And here is the original code:

C#
//======================================
namespace AlphaAssembly

internal class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine(Resource1.HW);

        A a2=new A2();
        a2.PrintMessage();

        A a3 = new A3();
        a3.PrintMessage();

        B b2 = new B2();
        b2.PrintMessage();

        B b3 = new B3();
        b3.PrintMessage();
    }
}

public class A
{
    public virtual void PrintMessage()
    {
        Console.WriteLine(Resource1.HWA);
    }
}

public class A2:A
{
    public override void PrintMessage()
    {
        Console.WriteLine(Resource1.HWA2);
    }
}

public class A3 : A
{
    public override void PrintMessage()
    {
        Console.WriteLine(Resource1.HWA3);
    }
}

//======================================
namespace BetaAssembly

public class B
{
    public virtual void PrintMessage()
    {
        Console.WriteLine("Hello World from B");
    }
}

public class B2 : B
{
    public override void PrintMessage()
    {
        Console.WriteLine("Hello World from B2");
    }
}    

public class B3 : B
{
    public override void PrintMessage()
    {
        Console.WriteLine("Hello World from B3");
    }
}  

3. Ildasm.exe

3.1. Details

3.2. Overview

You can start it from the command line:

Image 2

Basic assembly view:

Image 3

And here is the IL code of AlphaAssembly.A.PrintMessage() method:

Image 4

And here is Metadata info view:

Image 5

3.3. Impressions

  • License is not free, but it comes with Visual Studio, so most .NET developers will have it
  • Very basic functionality, almost at the level of “Proof of concept”
  • Just enable IL viewing, no decompiling into C# code

4. Telerik JustDecompile

4.1. Details

4.2. Overview

When I started the app and tried to load my AlphaAssembly.dll, I got a very unpleasant window:

Image 6

It wanted me to point it to .NET 7. Here is how I resolved it:

Image 7

Here is the basic assembly view:

Image 8

Here is class AlphaAssembly.A in IL:

Image 9

Here is class AlphaAssembly.A in C#:

Image 10

When we tried to reverse engineer BetaAssembly into C# project, we got this:

Image 11

Image 12

4.3. Impressions

  • It seems that this app is no longer maintained. It does not know how to handle .NET 7.
  • It can provide still useful decompiling to basic C# code on the file level.
  • Options present are functional but limited. Not so many fancy tools/options you can see in other products.
  • Strange for such a big name like “Telerik” that this app is in such bad shape. They advertise themselves as “Fastest Decompiler. 10 times faster than competitors.”, but in reality, it looks like an abandoned app.

5 dnSpyEx

5.1 Details

  • Product: dnSpyEx (continuation of dnSpy)
  • Company: OpenSource
  • Website: https://github.com/dnSpyEx/dnSpy
  • Platforms: Windows
  • License:  Licensed under GPLv3.
  • Note: GitHub: dnSpyEx is a unofficial continuation (fork) of the dnSpy project

5.2 Overview

Here is the basic assembly view:

Image 13

Here is class AlphaAssembly.A in IL:

Image 14

Here is class AlphaAssembly.A in C#:

Image 15

I was looking if I can reverse engineer BetaAssembly.dll into C# project but didn’t see that is possible.

Another nice thing is that it can show you PE format headers for the file/assembly:

Image 16

Fancy thing is that you can DEBUG assembly even if you do not have the source code. Here is a screenshot where we put a breakpoint into reverse-engineered code and run the assembly up to a breakpoint.

Image 17

This is a really fancy thing. Especially for the reverse engineering of some applications. You can monitor the state of variables in the debugger.

You can decompile into C# or VB.NET if you like.

Image 18

5.3 Impressions

  • Looks like a nice and stable Decompiler.
  • Really liked the PE format headers viewer.
  • Debugging is a really fancy feature. 
  • Some people will like the “decompile to VB.NET” feature, which many other decompilers do not offer.

6. ILSpy

6.1. Details

6.2. Overview

Here is the basic assembly view:

Image 19

Here is class AlphaAssembly.A in IL:

Image 20

Here is class AlphaAssembly.A in C#:

Image 21

Very fancy thing is that you can choose even the flavor/version of C# you want to see. That can be very interesting.

Image 22

When we tried to reverse engineer BetaAssembly into C# project, and it worked:

Image 23

Image 24

But we were not able to build the project right away. We got some build errors.

Image 25

Another nice thing is that it can show you PE format headers for the file/assembly. Just they hide everything under the generic name “Metadata”.

Image 26

6.3. Impressions

  • It looks like the project is regularly maintained and receives support from Microsoft.
  • Very fancy decompiling into a specific version of C#. I like that a lot.
  • Really liked the PE format headers viewer.
  • Reverse engineering into VS project is nice, it will probably work with some manual fine-tuning.

7. JetBrains dotPeek

7.1. Details

7.2. Overview

Here is the basic assembly view:

Image 27

Here is class AlphaAssembly.A in IL:

Image 28

Here is class AlphaAssembly.A in C#:

Image 29

Very fancy thing is that you can choose a Low-level/high-level version of C# you want to see. That can be very interesting.

Image 30

When we tried to reverse engineer BetaAssembly into C# project, and it worked:

Image 31

But we were not able to build the project right away. We got some build errors.

Image 32

Then I looked into the project file:

Image 33

Looks strange, it seems it created a .NET Framework style project with version 7.0. Who knows what happened here? But that is not usable.

Another nice thing is that it can show you PE format headers for the file/assembly. Just they hide everything under the generic name “Metadata”.

Image 34

It can create some nice dependency diagrams.

Image 35

Image 36

Another nice feature is that when you hover over some IL instruction, you get some hints about that instruction.

Image 37

7.3. Impressions

  • Feels really good, like a professional application with many navigation options.
  • Very fancy decompiling into Low-level/High-level of C#. I like that a lot.
  • Really liked the PE format headers viewer.
  • Reverse engineering into VS project had problems, which is strange for such a big name as JetBrains.
  • Dependency diagrams are a nice addition, they can be nice for documenting projects.

8. Conclusion

My personal favorite is:

If you are looking for a stable, feature-rich, nice graphical interface, and well-maintained application, dotPeek is your choice. That is the only .NET Decompiler you will ever need, and you can use it freely at home and at any workplace you will be working.

However, the other application that left a good impression is ILSpy (https://github.com/icsharpcode/ILSpy/releases ). It enabled decompiling into the selected version of C#, so it can be useful in analyzing and comparing different versions of the C# language.  

If you want to debug a .NET application without the source code, the only Decompiler that offers that is dnSpyEx (https://github.com/dnSpyEx/dnSpy/releases ).

But of course, preferences and opinions differ, so everyone is entitled to choose his or her own favorite tool and use it at will.

9. References

10. History

  • 1st March, 2023: Initial version

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Serbia Serbia
Mark Pelf is the pen name of just another Software Engineer from Belgrade, Serbia.
My Blog https://markpelf.com/

Comments and Discussions

 
QuestionVersions and dates when reviewed Pin
James H21-Dec-23 1:22
James H21-Dec-23 1:22 
PraiseRe: Versions and dates when reviewed Pin
Mark Pelf 25-Dec-23 0:19
mvaMark Pelf 25-Dec-23 0:19 
Question.NET 7 decompiler Pin
IssamTP8-Mar-23 22:42
IssamTP8-Mar-23 22:42 
AnswerRe: .NET 7 decompiler Pin
Mark Pelf 8-Mar-23 23:15
mvaMark Pelf 8-Mar-23 23:15 
QuestionRe: .NET 7 decompiler Pin
IssamTP14-Mar-23 0:11
IssamTP14-Mar-23 0:11 
AnswerRe: .NET 7 decompiler Pin
trønderen14-Mar-23 0:55
trønderen14-Mar-23 0:55 
GeneralRe: .NET 7 decompiler Pin
IssamTP14-Mar-23 4:31
IssamTP14-Mar-23 4:31 
AnswerRe: .NET 7 decompiler Pin
Mark Pelf 14-Mar-23 1:29
mvaMark Pelf 14-Mar-23 1:29 
QuestionGeneral Question about Decompiling .NET Pin
RunDosRun6-Mar-23 20:36
RunDosRun6-Mar-23 20:36 
AnswerRe: General Question about Decompiling .NET Pin
Mark Pelf 6-Mar-23 20:56
mvaMark Pelf 6-Mar-23 20:56 
GeneralRe: General Question about Decompiling .NET Pin
RunDosRun7-Mar-23 23:52
RunDosRun7-Mar-23 23:52 
QuestionObfuscators Pin
fcav6-Mar-23 11:08
fcav6-Mar-23 11:08 
AnswerRe: Obfuscators Pin
Mark Pelf 6-Mar-23 18:17
mvaMark Pelf 6-Mar-23 18:17 
GeneralRe: Obfuscators Pin
fcav7-Mar-23 10:53
fcav7-Mar-23 10:53 
SuggestionDecompiling VB.NET assemblies Pin
Christian Woltering6-Mar-23 4:52
Christian Woltering6-Mar-23 4:52 
Questionmy vote of 5 Pin
Southmountain3-Mar-23 4:02
Southmountain3-Mar-23 4:02 
GeneralMy vote of 5 Pin
Member 137041433-Mar-23 0:52
Member 137041433-Mar-23 0:52 
QuestionWhat about plugins? Pin
acblood2-Mar-23 8:18
acblood2-Mar-23 8:18 
PraiseRe: What about plugins? Pin
Mark Pelf 2-Mar-23 11:49
mvaMark Pelf 2-Mar-23 11:49 
PraiseThe clear winner is ... Pin
Christian Woltering1-Mar-23 0:16
Christian Woltering1-Mar-23 0:16 
PraiseRe: The clear winner is ... Pin
Mark Pelf 1-Mar-23 0:39
mvaMark Pelf 1-Mar-23 0:39 
GeneralRe: The clear winner is ... Pin
Fred Kreppert1-Mar-23 10:31
Fred Kreppert1-Mar-23 10:31 
I agree, the winner is not really quite so clear. Your conclusion is certainly justified by what you wrote, but there are some things that you are missing.

Last November I found myself needing to decompile a .NET assembly and so I looked into several different free .NET decompilers. This article https://blog.ndepend.com/in-the-jungle-of-net-decompilers/[^] proved to be very helpful in my search for the best decompiler to use.

I ultimately discovered that the dll I was decompiling was originally written in VB.NET. I write everything in C# myself and didn't even stop to think that the dll wasn't written in C#. I quickly discovered that not all decompilers can display code in both C# and VB. Further, code originally written in VB does no necessarily decompile in C# the same way as it would have been originally written. I therefore needed a decompiler that could show me the code in VB, and represent the original code as best as possible. I could then convert it to C# myself once I understood what the original writer intended for a routine to do. Being able to view the code in both VB and C# was a great help too as it greatly sped up my process of converting it to C#. The decompiler converted some of the code between the languages just fine, while other routines it did not. Had I relied solely on the C# decompile, some of the routines would not have come out with the same result as to what the routine was doing, and what the original writer of the routine intended for it to do.

This does seem a bit odd because both C# and VB are compiled to IL code in .NET. That IL code should in theory then be able to be decompiled to equivalent code in another language. Depending upon the decompiler though, this is not always the case. I think it also depends upon how the natively speaking writer wrote the original code in their language to begin with. Just as with spoken languages, the meaning of something in one language doesn't always have the same meaning in another language. IL code itself is just another language as well. Ultimately, the computer will produce the same result from the IL code, but it is how it is decompiled into a specific language that makes the difference.

In your review, you mention nothing other than the C# language. Not all compilers can handle both C# and VB. You make no mention of this in your review, despite referring to the article being about free decompilers in .NET, which can handle multiple languages.

The 2 decompilers which I focused on the most was dnSpy and ILSpy. I will address a third one shortly. ILSpy cannot handle displaying code in VB. In fact, it actually did the worst conversion of the IL code to C# when the original code was written in VB. Some of the routines wouldn't have even worked as it displayed them in C# code. dnSpy on the other hand can display code in both VB and C#. Its debugging capabilities also allowed me to step through the decompiled program and see exactly what the code was doing (after setting a breakpoint to the beginning of that code). This was a huge help when I came across VB code that I wasn't familiar with and the C# version was undecipherable as to the intent of the routine.

As a whole, dnSpy was much more helpful to me than ILSpy was for decompiling that dll. Every decompiler has its advantages and disadvantages, and for that project it was clearly dnSpy that was the clear overall winner.

I mentioned that there was a 3rd decompiler which I also looked at. You make no mention of this one at all, yet it is totally free. It doesn't have all the bells and whistles of some of the other decompilers, but it is free, and even web based (no other one you mention is web based). You can find it at Kani[^] To view code, simply drag a exe or dll file to the left side of the screen. Click on a routine on the left and the code for that routine will appear as C# code on the right of the screen. For simple viewing of the code as C# code, this decompiler is definitely very good. I did find that it decompiled the VB.NET code in a similar way that ILSpy does though. Some routines that were originally written in VB did not come out properly when viewed as C# code. In many cases, it was exactly the same code that ILSpy showed, and it was very unclear as to what the routine was supposed to be doing. It will only decompile to C#.

Although I find your article very good and it will probably help a lot of people, I had to give it 4 stars due to the fact that you don't mention at least VB.NET code at all. There are a lot of people on CP that use VB.NET and an article on .NET decompilers should at least give them some advice as well. Even with my being a C#.NET programmer, I had need for decompiling a dll originally written in VB.

As a side note, I think you have a word wrong in section 4.3. Your first point states "It seems that this app is no longer maintained. It does now know how to handle .NET 7." Shouldn't it say "It does not know how ..."?

Also, the version of dnSpy that you seem to be using (as pictured in the Overview at 5.2) shows v6.1.8. You also indicate that it seems to be no longer maintained as of Dec. 21, 2020. Last November (2022) I downloaded v6.2.0. I suspect I downloaded it from the dnSpyEx site that Christian Woltering mentions. Thus, it does still seem to be maintained.
PraiseRe: The clear winner is ... Pin
Mark Pelf 1-Mar-23 17:07
mvaMark Pelf 1-Mar-23 17:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.